<?php
/**
 * User: qianjin
 * Date: 2016/9/18 0018
 * Time: 15:18
 */
namespace model\all;

use dk\traits\Singleton;

class Site{

    protected static $instance;
    /**
     * @return \model\all\Site
     */
    public static function &getInstance() {
        if (!isset(static::$instance)) {
            self::$instance = new static();
        }

        return static::$instance;
    }

    protected $action;
    public function create($action){
        $this->action = $action;
        $config = $this->getConfig();
        if(isset($config[$action])){
            $this->id = $config[$action];
            $this->alias = $action;
            return true;
        }
        return false;
    }

    protected $id;
    protected $alias;
    protected $config = [];

    protected function getConfig(){
        if($this->config){
            return $this->config;
        }
        $config = file_get_contents(PATH_SITE . 'config/config_sites.php');
        return $this->config = json_decode($config, true);
    }

    public function getId(){
        return $this->id;
    }

    public function getAlias(){
        return $this->alias;
    }

}